package thread.join;

import lombok.SneakyThrows;

public class ThreadOfJoinTest {
    public static void main(String[] args) throws InterruptedException {
        Thread thread1 = new Thread(new Runnable() {
            @SneakyThrows
            @Override
            public void run() {
                //Thread.sleep(4000);
                System.out.println("线程1执行完毕");
            }
        });
        Thread thread2 = new Thread(new Runnable() {
            @Override
            public void run() {
                System.out.println("线程2执行完毕");
            }
        });
        thread1.start();
        thread2.start();
        thread1.join(0);
        thread2.join();
        doIt();
    }

    public static void doIt(){
        System.out.println("线程1和线程2执行完成后才到我执行");
    }
}
